import axios from "axios";

// axios.defaults.timeout = 10000;
axios.defaults.headers.post["Content-Type"] = "application/json";
axios.defaults.baseURL = "http://localhost:8848";

// 登陆
const _login = data => {
  return axios.post("/user/login", data);
};
// 注册
const _register = data => {
  return axios.post("/user/register", data);
};
// 获取二维码
const _eq = data => {
  return axios.post(`/user/eq`, data);
};
// 获取聊天室聊天记录
const _chatRoom = () => {
  return axios.get(`/chatRoom`);
};

// 创建帖子
const _create = data => {
  return axios.post("/blog/creatBlog", data);
};

// 获取详细帖子
const _detail = data => {
  return axios.post("/blog/Postdetails1", data);
};

// 获取所有的帖子
const _getAll = () => {
  return axios.get("/blog/allpost");
};

// 获取评论
const _getCommont = data => {
  return axios.post("/blog/getCommont", data);
};

// 创建评论
const _creatComment = data => {
  return axios.post("/blog/creatComment", data);
};

// 上传图片接口
const _upload = data => {
  return axios.post("/uploads", data);
};

// 根据用户id 获取信息
const _user = data => {
  return axios.post("/user/Retrieve", data);
};

const _saveChat = data => {
  return axios.post("/admin/saveChat", data);
};

const _getChat = data => {
  return axios.post("/admin/getChat", data);
};

// 修改昵称
const _realname = data => {
  return axios.post("/user/alterRealname", data);
};

// 修改资料
const _alter = data => {
  return axios.post("/user/alter", data);
};

export default {
  _login,
  _register,
  _eq,
  _create,
  _getAll,
  _chatRoom,
  _saveChat,
  _getChat,
  _detail,
  _user,
  _getCommont,
  _creatComment,
  _upload,
  _realname,
  _alter
};
